Skip to main content

identity

identity(int: integer) : Mat

param int - an integer representing the size of the identity matrix you want to create. An identity matrix is square so if int = 3, you'll get a 3x3 matrix.

returns: Mat - namely the identity matrix as a Mat object (matrix).

This function creates an identity matrix of int x int size. An identity matrix has all diagonal values as 1's and everything else as 0's. It is important in many operations because any matrix multiplied by the identity matrix (to the left, or right) is equal to the matrix itself.